$(document).ready(function() {
    $('#hideRules').click(function() {
        slided ? $('#reviewRules').slideDown(100) : $('#reviewRules').slideUp(100);
        slided = slided ? 0 : 1;
    });
    
    $('#formRev').submit(function() {
        $('#textError').css({'display':'none'});
        $('#ratingError').css({'display':'none'});
        var rating = $('#formRev').serializeArray();
        var text = tinyMCE.get('editor').getContent();
        if(!text) {
            $(tinymce.activeEditor.getBody()).css("background-color",'#FBC2C4');
            $(tinymce.activeEditor.getBody().parentNode).css("background-color",'#FBC2C4');
            $('#textError').css({'display':'block'});
        } 
        
        var isSelectRating = 0;
        for(var i = 0; i < rating.length; i++) 
            if(rating[i].name.indexOf('Reviews[ratings]') + 1) isSelectRating = 1;
        if(!isSelectRating) $('#ratingError').css({'display':'block'});
        if(!isSelectRating || !text) return false;
        return true;
    });
});